<div class="fsh-rightPanel">
    <div class="layui-anim layui-anim-upbit">
        <div id="list_form" class="layui-form-item wx-search">
            <div class="layui-inline">
                <input id="_schoolCode" type="hidden"  class="layui-input"  name="schoolCode" readonly/>
            </div>
            <div class="layui-inline">
                <input id="_schoolName" class="layui-input" placeholder="请选择学校"  autocomplete="off" readonly/>
            </div>
            <div class="layui-inline" style="padding-top: 5px">
                <input id="_squadName2" type="text" lay-verify="required" readonly placeholder="请选择班级" class="layui-input">
                <input id="_squadCode2" type="hidden" name="squadCode" lay-verify="required" readonly class="layui-input">
            </div>
            <button class="layui-btn btn-primary" id="search">搜索</button>
            <button class="layui-btn btn-primary" id="clear">清除</button>
        </div>
        <table id="list_table" class="layui-hide" lay-filter="mainList"></table>
    </div>
</div>

<script type="text/html" id="btnBar">
<!--  table 数据操作按钮  -->
<!--    <a href="javascript:;" class="font-primary" lay-event="user">成员管理</a>-->
</script>

<script>
    layui.use(['layer', 'table'], function () {
        var layer = layui.layer;
        var table = layui.table;
        var tableObj = table.render({
            elem: '#list_table'
            , url: context + '/api/eduCourseHistory/list'
            , where: util.getFormData(DEFAULT_FORMID)
            //开启头部工具栏，并为其绑定左侧模板，
           ,request: {
                limitName: 'pageSize' //每页数据量的参数名，默认：limit
            }
            , page: true
            //, defaultToolbar: ['filter', 'exports', 'print', {}]
            , align: 'center'
            , cols: [[ //表头
                // {type: 'checkbox', fixed: 'left'},
                // {field: 'courseId', title: '课程ID', align: 'center'},
                {field: 'title', title: '课程', align: 'center'},
                {field: 'createUserId', title: '用户ID', align: 'center', templet: function (d) {
                    return d._user? d._user.nickname:"";
                    }},
                {field: 'startDate', title: '开始时间', align: 'center'},
                {field: 'endDate', title: '结束时间', align: 'center'},
                {field: 'keepTime', title: '持续时间(毫秒)', align: 'center'},
                {field: 'type', title: '类型(1直播,2录播)', align: 'center', templet: function (d) {
                    return d.type == 1?"直播": d.type == 2?"录播":"";
                }},
                // {field: 'push', title: '推流或者拉流(1推，2拉)', align: 'center'},
                {field: 'addr', title: 'IP', align: 'center'},
                {field: 'record', title: '录像地址', align: 'center'},
            ]]
        });
        // 检索
        $("#search").click(function () {
            reloadTable(tableObj);
        });
        // 清除搜索条件
        $("#clear").click(function () {
            $("#list_form input").val('');
        });

        //表格内部操作按钮监听
        table.on('tool(mainList)', function (obj) { //注：tool是工具条事件名，mainList是table原始容器的属性 lay-filter="对应的值"
            var data = obj.data; //获得当前行数据
            var layEvent = obj.event; //获得 lay-event 对应的值
            if (layEvent === 'update') {//编辑
                showDialog({
                    title: '编辑 - ' + data.squad_name
                    , template: 'add'
                    , saveUrl: context + '/api/eduCourseHistory/update'
                    , tableObj: tableObj
                    , htmlData: data
                    , type: "patch"
                    , dataType: 'json'
                })
            }
        });

        //选择学校
        selectSchool();

        //选择班级
        selectSquad('_squadName2','_squadCode2');
    });
</script>
